<template>
  <div class="container">
    <van-nav-bar @click-right="showMsg">
      <!--<van-icon size="20" name="arrow-left" slot="left" color="rgb(150, 151, 153)"/>-->
      <p slot="title" style="font-size: 14px">个人中心</p>
      <template #right>
        <van-icon v-if="badge" name="chat-o" :badge="badge" size="18" color="#000"/>
        <van-icon v-else name="chat-o" size="18" color="#000"/>
      </template>
    </van-nav-bar>
    <div class="header">
      <van-image
          width="100px"
          height="100px"
          round
          fit="cover"
          src="https://joeschmoe.io/api/v1/random"
          style="margin-top: 15px"/>
      <h4>普通用户</h4>
    </div>
    <van-cell-group style="margin-top: 15px">
      <van-cell title="足迹" @click="footprint">
        <template #icon>
          <img src="img/icon-foot.png" width="16" height="18" style="position: relative;top: 2px;margin-right: 10px"/>
        </template>
      </van-cell>
      <van-cell title="我的订单" @click="order">
        <template #icon>
          <img src="img/icon-order.png" width="17" height="20" style="position: relative;top: 2px;margin-right: 8px"/>
        </template>
      </van-cell>
      <van-cell title="我的评价" @click="comment">
        <template #icon>
          <img src="img/icon-comment.png" width="18" height="20" style="position: relative;top: 2px;margin-right: 8px"/>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group style="margin-top: 13px">
      <van-cell title="问题反馈" @click="feedback">
        <template #icon>
          <img src="img/icon-back.png" width="18" height="22" style="position: relative;top: 2px;margin-right: 8px"/>
        </template>
      </van-cell>
      <van-cell title="联系客服" @click="concats">
        <template #icon>
          <img src="img/icon-chat.png" width="18" height="18" style="position: relative;top: 2px;margin-right: 8px"/>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group style="margin-top: 13px">
      <van-cell title="设置" @click="setting">
        <template #icon>
          <img src="img/icon-setting.png" width="18" height="18" style="position: relative;top: 2px;margin-right: 8px"/>
        </template>
      </van-cell>
    </van-cell-group>
  </div>
</template>

<script>
import Vue from 'vue'
import { NavBar, Image as VanImage, Panel, CellGroup, Cell } from 'vant'
import { requestUnReadCount } from '../../api/msg'

Vue.use(NavBar)
Vue.use(VanImage)
Vue.use(Panel)
Vue.use(CellGroup)
Vue.use(Cell)

export default {
  name: 'keep',
  data () {
    return {
      badge: 0
    }
  },
  created () {
    requestUnReadCount().then(res => {
      console.log(res)
      this.badge = res.count
    })
  },
  methods: {
    showMsg () {
      this.$router.push('/message')
    },
    footprint () {
      this.$router.push('/footprint')
    },
    order () {
      console.log('订单')
      this.$router.push('/order')
    },
    wait(){
      console.log('待支付订单')
    },
    comment () {
      this.$router.push('/mycomment')
    },
    feedback () {
      this.$router.push('/feedback')
    },
    concats () {
      window.open('http://wpa.qq.com/msgrd?v=3&uin=3320938770&site=qq&menu=yes')
    },
    setting () {
      this.$router.push('/setting')
    }
  }
}
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  overflow: auto;
  text-align: left;

  .header {
    background-color: #fff;
    text-align: center;
    padding-bottom: 10px;
  }

  .panel {
    padding: 10px 16px;
    font-size: 12px;
    line-height: 1.6;
  }
}
</style>
